﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace NetCDF
{
public enum NC_Type
        {
            NC_NAT,
            NC_BYTE,
            NC_CHAR,
            NC_SHORT,
            NC_INT,
            NC_FLOAT,
            NC_DOUBLE,
            NC_UBYTE,
            NC_USHORT,
            NC_UINT,
            NC_INT64,
            NC_UINT64,
            NC_STRING
        }
	public static class LowAPI
	{
		[DllImport("netcdf.dll")]
        public static extern int nc_inq_dim(int ncid, int dimid,StringBuilder nameb, ref int len);
		[DllImport("netcdf.dll")]
		public static extern int nc_inq_varname(int ncid, int varid, StringBuilder name);
		[DllImport("netcdf.dll")]
		public static extern int nc_get_var_float(int ncid, int varid, float[] ip);
		[DllImport("netcdf.dll")]
		public static extern int nc_get_var_short(int ncid, int varid, short[] ip);
		[DllImport("netcdf.dll")]
		public static extern int nc_get_var_int(int ncid, int varid, int[] ip);
		[DllImport("netcdf.dll")]
		public static extern int nc_inq_varndims(int ncid, int varid, ref int ndim);
		[DllImport("netcdf.dll")]
		public static extern int nc_inq_vardimid(int ncid, int varid, int[] dimid);
		[DllImport("netcdf.dll")]
		public static extern int nc_get_vara_int(int ncid, int varid, int[] start, int[] count, int[] ip);
		[DllImport("netcdf.dll")]
		public static extern int nc_get_vara_float(int ncid, int varid, int[] start, int[] count, float[] ip);
		[DllImport("netcdf.dll")]
		public static extern int nc_get_vara_double(int ncid, int varid, int[] start, int[] count, double[] ip);
		[DllImport("netcdf.dll")]
		public static extern int nc_inq_vartype(int ncid, int varid, ref NC_Type type);
		[DllImport("netcdf.dll")]
		public static extern int nc_inq_att(int ncid, int varid, string name, ref NC_Type type, ref int len);
		[DllImport("netcdf.dll")]
		public static extern int nc_inq_varnatts(int ncid, int varid, ref int nattsp);
		[DllImport("netcdf.dll")]
		public static extern int nc_inq_attname(int ncid, int varid, int attnum, StringBuilder name);
		[DllImport("netcdf.dll")]
		public static extern int nc_get_att_text(int ncid, int varid, string name, StringBuilder value);
		[DllImport("netcdf.dll")]
		public static extern int nc_open(string filename, int mode, ref int id);
		[DllImport("netcdf.dll")]
		public static extern int nc_create(string path, int 	cmode, ref int ncidp);
		[DllImport("netcdf.dll")]
		public static extern int nc_close(int ncidp);
		[DllImport("netcdf.dll")]
		public static extern int nc_inq_nvars(int ncidp, ref int nvars);
		[DllImport("netcdf.dll")]
		public static extern int nc_inq_varid(int ncid, string nvars, ref int varid);
		[DllImport("netcdf.dll")]
		public static extern int nc_inq_ndims(int ncid, ref int ndimsp);
		[DllImport("netcdf.dll")]
		public static extern int nc_inq_dimname(int ncid, int dimid, StringBuilder name);
		[DllImport("netcdf.dll")]
		public static extern int nc_inq_unlimdim(int ncid, ref int unlimdimid);
		[DllImport("netcdf.dll")]
		public static extern int nc_get_att_short(int ncid, int varid, string name, ref short value);
		[DllImport("netcdf.dll")]
		public static extern int nc_get_att_int(int ncid, int varid, string name, ref int value);
		[DllImport("netcdf.dll")]
		public static extern int nc_get_att_long(int ncid, int varid, string name, ref long value);
		[DllImport("netcdf.dll")]
		public static extern int nc_get_att_float(int ncid, int varid, string name, ref float value);
		[DllImport("netcdf.dll")]
		public static extern int nc_get_att_double(int ncid, int varid, string name, ref double value);
		[DllImport("netcdf.dll")]
		public static extern int nc_def_dim(int ncid, string name, int len, ref int id);
		[DllImport("netcdf.dll")]
		public static extern int nc_def_var(int ncid, string name, NC_Type type, int 	ndims, int[] dimids, ref int varid);
		[DllImport("netcdf.dll")]
		public static extern int nc_enddef(int ncid);

		[DllImport("netcdf.dll")]
		public static extern int nc_put_vara_float (int ncid, int varid, int[] start, int[] countp, float[] op);
		
		
	}
}
